Q=@
CFLAGS=-Wall

CC=g++

NAME=astrotime.so
SRC=misc.cpp time.cpp
HDR=misc.h time.h
LIB=-lcspice
OBJ=$(SRC:.cpp=.o)

prefix=/usr/local

includedir=$(prefix)/include
libdir=$(prefix)/lib

all: $(NAME)

# The variable $@ has the value of the target. In this case $@ = prog
$(NAME): $(OBJ)
	$(Q)$(CC) -shared -o $@ $(OBJ) $(LIB)

install: $(NAME)
	install -m 0644 $(HDR) $(prefix)/include
	install -m 0644 $(NAME) $(prefix)/lib

uninstall:
	for i in $(HDR) ; do \
		rm $(includedir)/$$i ; \
	done
	rm $(libdir)/$(NAME)

%.o: %.cpp
	$(Q)echo $@
	$(Q)$(CC) -fPIC -c -o $@ $<

.PHONY: clean mrproper install uninstall

clean:
	$(Q)rm -f *.o *~ $(NAME)

mrproper: clean
	$(Q)rm -rf $(NAME)
